package com.zhijian.medical.controller;


import com.zhijian.medical.annotation.CurrentUser;
import com.zhijian.medical.annotation.Response;
import com.zhijian.medical.entity.dto.PersonDto;
import com.zhijian.medical.entity.vo.request.MedicalDeviceSearchVo;
import com.zhijian.medical.entity.vo.request.RfidSearchVo;
import com.zhijian.medical.entity.vo.response.HarmfulVo;
import com.zhijian.medical.entity.vo.response.MedicalDeviceVo;
import com.zhijian.medical.entity.vo.response.RfidVo;
import com.zhijian.medical.service.MonitorService;
import com.zhijian.medical.service.SensorService;
import com.zhijian.medical.util.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * 监测设备
 *
 * @author HCG
 * @version 1.0
 * @date 2022-01-22 15:30:23
 */
@Slf4j
@Controller
@Api(tags = "监测设备")
public class MonitorController {


    @Autowired
    private SensorService sensorService;

    @Autowired
    private MonitorService monitorService;

    /**
     * 传感器列表查询
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("monitor/page")
    @ApiOperation("传感器列表查询")
    public Page<MedicalDeviceVo> selectByCondition(@CurrentUser @ApiIgnore PersonDto personDto,
                                                   @RequestBody(required = false) MedicalDeviceSearchVo param) {
        if (param == null)
            param = MedicalDeviceSearchVo.builder().build();
        //todo 暂时注释掉
//      param.setGroupIds(personDto.getGroupIds());
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);

        return sensorService.selectPage(param);
    }

    /**
     * rfid列表查询
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("monitor/page/list")
    @ApiOperation("rfid列表查询")
    public List<MedicalDeviceVo> selectByConditionList(@CurrentUser @ApiIgnore PersonDto personDto,
                                                       @RequestBody(required = false) MedicalDeviceSearchVo param) {
        if (param == null)
            param = MedicalDeviceSearchVo.builder().build();
        //todo 暂时注释掉
//      param.setGroupIds(personDto.getGroupIds());
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
        param.setDeviceType("2");
        return sensorService.selectList2(param);
    }



    /**
     * 详情内容
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("monitor/page/details")
    @ApiOperation("详情内容")
    public Page<RfidVo> selectByDetails(@CurrentUser @ApiIgnore PersonDto personDto,
                                        @RequestBody(required = false) RfidSearchVo param) {
        if (param == null)
            param = RfidSearchVo.builder().build();
        //todo 暂时注释掉
//        param.setGroupIds(personDto.getGroupIds());
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);

        return monitorService.selectByDetails(param);
    }
}
